@echo off
chcp 65001 >nul
title Install Dependencies

echo ======================================================================
echo                 Installing Required Dependencies
echo ======================================================================
echo.
echo This will install all required Python packages...
echo.

cd /d "%~dp0"

REM Check if requirements.txt exists
if not exist "requirements.txt" (
    echo.
    echo ERROR: requirements.txt not found!
    echo Please make sure you are running this script in the correct directory.
    echo.
    pause
    exit /b 1
)

echo Checking Python and pip...
python --version
if errorlevel 1 (
    echo.
    echo ERROR: Python is not installed or not in PATH!
    echo.
    pause
    exit /b 1
)

pip --version
if errorlevel 1 (
    echo.
    echo ERROR: pip is not available!
    echo.
    pause
    exit /b 1
)

echo.
echo Installing from requirements.txt...
echo.

pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple

if errorlevel 1 (
    echo.
    echo ======================================================================
    echo Installation failed!
    echo ======================================================================
    echo.
    echo Please check:
    echo   1. Python is installed correctly
    echo   2. pip is available
    echo   3. Internet connection is working
    echo   4. No permission issues
    echo.
    echo You can also try:
    echo   pip install -r requirements.txt
    echo.
    pause
    exit /b 1
)

echo.
echo ======================================================================
echo Installation completed successfully!
echo ======================================================================
echo.
echo You can now run the test program.
echo.

pause
